package com.itmiaojie.quartz;

import com.itmiaojie.constant.RedisConstant;
import com.itmiaojie.utils.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.JedisPool;

import java.util.Set;

public class ClearImgJob {
    @Autowired
    private JedisPool jedisPool;
    public void clearImg(){
        Set<String> set = jedisPool.getResource().
                sdiff(RedisConstant.SETMEAL_PIC_RESOURCES, RedisConstant.SETMEAL_PIC_DB_RESOURCES);
        for (String name : set) {
            //删除七牛云服务器上的图片
            QiniuUtils.deleteFileFromQiniu(name);
            //从Redis集合中删除图片名称
            jedisPool.getResource().srem(name);
        }


    }



}
